﻿using sx_windows.common;
using sx_windows.data.repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sx_windows.pane.router
{
    class RouterSettingPresenter : RouterSettingContract.Presenter
    {
        private RouterSettingContract.View mView;
        private RouterSettingRepository routerSettingRepository;
        public RouterSettingPresenter(RouterSettingContract.View view)
        {
            this.mView = view;
            routerSettingRepository = RouterSettingRepository.Instance();
        }

        public void init()
        {
            string address = routerSettingRepository.GetRouterConfig().Address;
            string user = routerSettingRepository.GetRouterConfig().User;
            string password = routerSettingRepository.GetRouterConfig().Password;
            mView.SetRouterAddress(address);
            mView.SetUser(user);
            mView.SetPassword(password);
        }

        public void SaveBtnClick()
        {
            mView.ShowBottomText("已保存");
            string address = mView.GetRouterAddress();
            string user = mView.GetUser();
            string password = mView.GetPassword();
            routerSettingRepository.SaveRouterConfig(address, user, password);
            mView.SetTabIndex(0);
        }
    }
}
